package com.yeung.exam;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

/**
 * 判断两个字符串是否具有相同的模式
 * aba
 * xyx
 * 是一样的模式
 */
public class 相似字符串 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String patern = scanner.nextLine();
        String match = encode(scanner.nextLine());
        int ens = 0;
        for (int i = 0; i <= patern.length() - match.length(); i++) {
            String patSub = patern.substring(i, i + match.length());
            if (encode(patSub).equals(match)) {
                ens++;
            }
        }
        System.out.println(ens);

    }

    public static String encode(String line) {
        char[] chars = line.toCharArray();
        Map<Character, Integer> coded = new HashMap<>();
        StringBuilder result = new StringBuilder();
        int codeNow = 0;
        for (int i = 0; i < chars.length; i++) {
            char aChar = chars[i];
            if (coded.containsKey(aChar)) {
                Integer codeNum = coded.get(aChar);
                result.append(codeNum);

            } else {
                coded.put(aChar, codeNow);
                result.append(codeNow);
                codeNow++;
            }

        }
        return result.toString();

    }
}
